
const LOCAL_DATA = 'urlDataList'

let getUrlDataList = () => {
    let urlDataList = localStorage.getItem(LOCAL_DATA);
    try { urlDataList = JSON.parse(urlDataList) } catch (err) { urlDataList = [] };
    return urlDataList;
}

let setUrlDataList = (data) => {
    if (typeof data === 'object') data = JSON.stringify(data);
    localStorage.setItem(LOCAL_DATA, data);
}

let removeUrlDataList = () => {
    localStorage.removeItem(LOCAL_DATA);
}

var http = axios.create({
    // baseURL: 'http:127.0.0.1:3000/api',
    timeout: 10000
})

// 请求拦截器
http.interceptors.request.use(config => {
    return config
}, err => {
    console.log('请求拦截器err', err)
    return Promise.reject(err)
})

// 响应拦截器
http.interceptors.response.use(res => {
    console.log('响应拦截器res', res)
    let { data: { code, msg } } = res
    return res
}, err => {
    console.log('响应拦截器err', err)
    return Promise.reject(err)
})